--- @param extension Package
--- @param HY HY_Utility
--- @param U Utility
return function(extension, HY, U)
    local hy_konpaku_youmu = General:new(extension, "hy_konpaku_youmu", "chi_k", 1, 1, General.Female)
    hy_konpaku_youmu.shield = 2
    local truth_insight = fk.CreateSkill {
        name = "truth_insight",
    }
    truth_insight:addEffect(fk.Damaged, {
        anim_type = "masochism",
        can_trigger = function(self, event, target, player, data)
            return player:hasSkill(truth_insight.name) and target == player
        end,
        on_trigger = function(self, event, target, player, data)
            event:setSkillData(self, "cancel_cost", false)
            for _ = 1, data.damage do
                if event:getSkillData(self, "cancel_cost") or not player:hasSkill(self) then break end
                self:doCost(event, target, player, data)
            end
        end,
        on_cost = function(self, event, target, player, data)
            local room = player.room
            if room:askToSkillInvoke(player, {
                    skill_name = truth_insight.name,
                    prompt = "truth_insight_prompt"
                }) then
                return true
            end
            event:setSkillData(self, "cancel_cost", true)
        end,
        on_use = function(self, event, target, player, data)
            local room = player.room
            room:drawCards(player, 2, truth_insight.name)
            room:setPlayerMark(player, "@@truth_insight-turn", 1)
        end,
    })
    truth_insight:addEffect(fk.TurnEnd, {
        anim_type = "masochism",
        can_trigger = function(self, event, target, player, data)
            return player:hasSkill(truth_insight.name) and player:getMark("@@truth_insight-turn") > 0
        end,
        on_cost = function(self, event, target, player, data)
            local room = player.room
            if not player:canUse(Fk:cloneCard("slash"), { bypass_times = true }) or player:prohibitUse(Fk:cloneCard("slash")) then
                return false
            end
            local use = room:askToUseCard(player, {
                skill_name = "slash",
                pattern = "slash",
                prompt = "truth_insight_prompt_use",
                extra_data = {
                    bypass_times = true,
                }
            })
            if use then
                use.extraUse = true
                room:setCardMark(use.card, "truth_insight", player.id)
                event:setCostData(self, use)
                return true
            end
        end,
        on_use = function(self, event, target, player, data)
            local room = player.room
            room:useCard(event:getCostData(self))
        end,
    })
    truth_insight:addEffect(fk.CardUseFinished, {
        can_refresh = function(self, event, target, player, data)
            return player:hasSkill(truth_insight.name) and data.card and data.card:getMark("truth_insight") == player.id
        end,
        on_refresh = function(self, event, target, player, data)
            if data.damageDealt and
                table.any(data.damageDealt, function(value)
                    return value > 0
                end) then
                player.room:changeShield(player, 1)
            end
            player.room:setCardMark(data.card, "truth_insight", 0)
        end,
    })
    local suffer_loop = fk.CreateSkill {
        name = "suffer_loop",
    }
    suffer_loop:addEffect(fk.AfterCardsMove, {
        can_trigger = function(self, event, target, player, data)
            return player:hasSkill(suffer_loop.name) and #table.filter(data, function(move)
                return move.to == player and move.toArea == Card.PlayerHand and #move.moveInfo >= 2
            end) > 0 and #player:getCardIds("h") >= 2
        end,
        on_cost = function(self, event, target, player, data)
            local room = player.room
            local targets, cards = room:askToChooseCardsAndPlayers(player, {
                min_card_num = 2,
                max_card_num = 2,
                targets = room:getOtherPlayers(player),
                min_num = 1,
                max_num = 1,
                pattern = ".|.|.|hand",
                prompt = "suffer_loop_prompt",
                skill_name = suffer_loop.name,
            })
            if #targets == 0 or #cards == 0 then
                return false
            end
            event:setCostData(self, { targets[1], cards })
            return true
        end,
        on_use = function(self, event, target, player, data)
            local room = player.room
            room:moveCards({
                from = player,
                toArea = Card.PlayerHand,
                to = event:getCostData(self)[1],
                proposer = player,
                ids = event:getCostData(self)[2],
                skillName = suffer_loop.name,
                moveReason = fk.ReasonGive,
                moveVisible = false,
            })
            if player.shield > 0 and not player.dead then
                room:drawCards(player, 1, suffer_loop.name)
            end
        end,
    })
    local divided_spirit = fk.CreateSkill {
        name = "divided_spirit",
    }
    divided_spirit:addEffect(fk.EventPhaseChanging, {
        can_trigger = function(self, event, target, player, data)
            if not player:hasSkill(divided_spirit.name) or target ~= player then
                return false
            end
            return data.phase == Player.Judge and player.shield <= 0
        end,
        on_cost = Util.TrueFunc,
        on_use = function(self, event, target, player, data)
            data.skipped = true
        end,
    })
    divided_spirit:addEffect("targetmod", {
        bypass_distances = function(self, player, skill, card, to)
            return player:hasSkill(divided_spirit.name) and card.trueName == "slash" and player.shield > 0
        end,
        bypass_times = function(self, player, skill, scope, card, to)
            if player:hasSkill(divided_spirit.name) and skill.trueName == "slash_skill" and player.shield <= 0 then
                return true
            end
        end,
    })
    divided_spirit:addEffect("maxcards", {
        correct_func = function(self, player)
            if player:hasSkill(divided_spirit.name) and player.shield and player.shield > 0 then
                return 2
            end
        end,
    })
    extension:loadSkillSkels { truth_insight, suffer_loop, divided_spirit }
    hy_konpaku_youmu:addSkill("truth_insight")
    hy_konpaku_youmu:addSkill("suffer_loop")
    hy_konpaku_youmu:addSkill("divided_spirit")
    Fk:loadTranslationTable {
        ["hy_konpaku_youmu"] = "魂魄妖梦",
        ["#hy_konpaku_youmu"] = "分一为二",
        ["illustrator:hy_konpaku_youmu"] = "イス",
        ["designer:hy_konpaku_youmu"] = "黑曜人形",
        ["cv:hy_konpaku_youmu"] = "",

        ["truth_insight"] = "空观",
        [":truth_insight"] = "在你受到1点伤害后，你可以摸两张牌。若如此做，你可以于本回合结束时使用一张【杀】，若此【杀】造成了伤害，你获得1点护甲。",
        ["truth_insight_prompt"] = "空观：你可以摸两张牌",
        ["@@truth_insight-turn"] = "空观",
        ["truth_insight_use"] = "使用一张杀",
        ["truth_insight_shield"] = "失去护甲并视为使用杀",

        ["truth_insight_viewas"] = "空观",
        ["truth_insight_prompt_use"] = "空观：你可以使用一张【杀】，若此【杀】造成了伤害，你获得1点护甲",
        ["truth_insight_prompt_shield"] = "空观：你可以失去1点护甲并视为使用一张【杀】",

        ["suffer_loop"] = "苦轮",
        [":suffer_loop"] = "在你一次性获得至少两张牌后，你可以交给一名其他角色两张手牌。然后若你有护甲，你摸一张牌。",
        ["suffer_loop_prompt"] = "苦轮：你可以交给一名其他角色两张手牌",
        ["#suffer_loop_targetmod"] = "苦轮",

        ["divided_spirit"] = "分魄",
        [":divided_spirit"] = "若你有护甲，你的手牌上限+2且使用【杀】无距离限制；若你没有护甲，你跳过判定阶段且使用【杀】无次数限制。",
        ["#divided_spirit_targetmod"] = "分魄",
        ["#divided_spirit_maxcard"] = "分魄",
    }
end
